<template>
  <div class="comment-info" v-if="Object.keys(commentInfo).length !== 0">
    <!-- 评论标题 -->
    <div class="comment-title">
      <div>用户评价</div>
      <div class="comment-more">更多</div>
    </div>
    <!-- 评论用户 -->
    <div class="user-info">
      <img :src="commentInfo.user.avatar" alt="" />
      <span>{{ commentInfo.user.uname }}</span>
    </div>
    <!-- 评论内容 -->
    <div class="comment-detail">
      <!-- 内容 -->
      <p>{{ commentInfo.content }}</p>
      <!-- 时间戳和类型 -->
      <div class="info-other">
        <span>{{ commentInfo.created | showDate }}</span>
        <span>{{ commentInfo.style }}</span>
      </div>
      <!-- 买家秀 -->
      <div class="info-img">
        <img v-for="item in commentInfo.images" :key="item" :src="item" />
      </div>
    </div>
  </div>
</template>

<script>
import { formatDate } from 'common/utils'
export default {
  name: 'DetailCommentInfo',
  props: {
    commentInfo: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  filters: {
    showDate(value) {
      let date = new Date(value * 1000)
      return formatDate(date, 'yyyy-MM-dd')
    }
  }
}
</script>

<style type="text/css" scoped>
.comment-info {
  font-size: 14px;
  padding: 20px 15px;
  border-bottom: 5px solid #f2f5f8;
}
.comment-title {
  display: flex;
}
.comment-title div {
  flex: 1;
}
.comment-more {
  padding-right: 20px;
  text-align: right;
  position: relative;
}
.comment-more::after {
  content: '';
  height: 10px;
  width: 10px;
  position: absolute;
  top: 3px;
  right: 5px;
  border-width: 1px;
  border-style: solid;
  border-color: #333 #333 transparent transparent;
  transform: rotateZ(45deg);
}
.user-info {
  display: flex;
  margin-top: 15px;
  line-height: 50px;
}
.user-info img {
  width: 45px;
  height: 45px;
  margin-right: 15px;
  border-radius: 50%;
}
.comment-detail p {
  margin-top: 5px;
  padding-bottom: 10px;
}
.comment-detail span {
  padding: 10px 0;
  margin-right: 20px;
}
.info-img img {
  width: 10vh;
  height: 11vh;
  padding: 5px 0;
  border-radius: 8px;
  margin-right: 5px;
}
</style>
